#include <bits/stdc++.h>
static double quality=1e-12;
double func(double t) {
    return 12.f*(t)+3+7.f/t;
}
template<class T, int n> void GaussianElidemo(std::array<std::array<T,n+1>,n> a) {
	for(int i=1;i<=n;i++) {
		int maxx=i;
		for(int j=1;j<=n;j++) {
			if(fabs(a[j][j])>quality&&j<i) continue;
			if(fabs(a[j][i])-fabs(a[maxx][i])>quality) {
				maxx=j;
			}
		}
		for(int j=1;j<=n+1;j++)
			std::swap(a[maxx][j],a[i][j]);
		if(fabs(a[i][i])<=quality)
			continue;
		for(int j=1;j<=n;j++) {
			if(i==j) continue;
			double delta=a[j][i]/a[i][i];
			for(int k=i;k<=n+1;k++) {
				a[j][k]-=delta*a[i][k];
			}
		}
	}
	std::cout << "f(x) = ";
	double t=0.f;
	for(int i=n;i>=1;i--)
		t+=a[i][n+1]/(a[i][i]+1e-8)*sin(pow(12,i-1));
	for(int i=n;i>=1;i--)
		printf("[%.3lf·sin (x`%d)]%c      %c",a[i][n+1]/(a[i][i]+1e-8),i-1,"\n."[i==1],"+"[i==1]);
	printf("\n\nf(12)=%lf=vgm(12)=%lf",t,func(12));
	return ;
}
int main(void) {
    const int n=143;
    std::array<std::array<double,n+1>,n> a;
    std::vector<double> sample(n);
    std::vector<double> result(n);
    puts("\033cVGM Function: f(x)=12x+3+7/x");
	for(int i=1;i<=n;i++) sample[i]=i,result[i]=func(i);
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=n;j++)
			a[i][j]=sin(pow(sample[i],j-1));
		a[i][n+1]=result[i];
	}
	GaussianElidemo<double,n>(a);
	puts("\033[8m");
	return 0;
}